package builder;

import java.util.List;
import java.util.Map;

public class DocumentDirector {
    private DocumentBuilder builder;

    public DocumentDirector(DocumentBuilder builder) {
        this.builder = builder;
    }

    // 构建简单文档（标题+正文）
    public Document buildSimpleDocument(String title, String content) {
        builder.setTitle(title);
        builder.setContent(content);
        return builder.getDocument();
    }

    // 构建完整文档（标题+正文+图片+附件）
    public Document buildCompleteDocument(
            String title, String content,
            List<Map<String, String>> images,
            List<Map<String, String>> attachments) {
        builder.setTitle(title);
        builder.setContent(content);
        // 添加图片
        for (Map<String, String> imgMap : images) {
            builder.addImage(imgMap.get("url"), imgMap.get("alt"));
        }
        // 添加附件
        for (Map<String, String> attachMap : attachments) {
            builder.addAttachment(attachMap.get("name"), attachMap.get("path"));
        }
        return builder.getDocument();
    }
}